from django.shortcuts import render_to_response, get_object_or_404
from race_stats.mobile import mobile_browser
from teams.models import Team, Runner


#
#
#
def index(request):
    team_list = Team.objects.all().order_by('number')
    if mobile_browser:
        template = 'teams/m_index.html'
    else:
        template = 'teams/index.html'
    return render_to_response(template, {'team_list': team_list})


#
#
#
def detail(request, team_id):
    team = get_object_or_404(Team, pk=team_id)
    if mobile_browser:
        template = 'teams/m_detail.html'
    else:
        template = 'teams/detail.html'
    return render_to_response(template, {'team': team})

